<template>
    <div>
      <keep-alive :include="includsname">
        <router-view></router-view>

      </keep-alive>
    </div>
</template>
<script>
  import axios from "axios";

  export default {
    
    name: 'xiaoxitongzhi',
    data() {
      return {
        includsname:[],
      shopid:''
      }
    },
    created(){
      var that = this
      this.shopid = JSON.parse(localStorage.getItem('SHOP')).shop_id

      var namearr = []
      var getarr = JSON.parse(localStorage.getItem('LOCAL_NAV'+this.shopid))
      for(var x = 0;x<getarr.length;x++){
        namearr.push(getarr[x].name1)
        if(getarr[x].name2!=''){
          namearr.push(getarr[x].name2)
        }
      }
      that.includsname = namearr
      // console.log('namearr——app')
      //     console.log(that.includsname)
    },
    mounted(){
      
      var that = this
      
      // 监听localhostStorage的数据变化，结合utils/tool.js配合使用
      window.addEventListener('setItemEvent', function(e) {
        var namearr = []
        if(e.key == 'LOCAL_NAV'+that.shopid){
          var getarr = JSON.parse(e.newValue)
          for(var x = 0;x<getarr.length;x++){
            namearr.push(getarr[x].name1)
            if(getarr[x].name2!=''){
              namearr.push(getarr[x].name2)
            }
          }
          that.includsname = namearr
          // console.log('namearr——app')
          // console.log(that.includsname)
        }
       
       
        
      })
    },
  }
</script>

<style lang="scss" scoped>
 
</style>